package reduce.fz.com.reduce.adapter;

import android.app.Activity;
import android.content.Context;
import android.media.Image;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.List;

import reduce.fz.com.reduce.R;
import reduce.fz.com.reduce.bean.FindBanner;
import reduce.fz.com.reduce.util.PicassoUtil;

/**
 * Created by qingshengzheng on 15/7/31.
 */
public class BannerAdapter extends PagerAdapter {
    private List<FindBanner> banners;
    private Context context;
    private LayoutInflater layoutInflater;

    public BannerAdapter(List<FindBanner> banners, Context  context) {
        this.banners = banners;
        this.context = context;
        layoutInflater = LayoutInflater.from(context);

    }

    @Override
    public int getCount() {
        return banners.size();
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view = layoutInflater.inflate(R.layout.view_find_banner, container, false);
        ImageView imageView = (ImageView) view.findViewById(R.id.banner_image);
        PicassoUtil.laodUrl(view.getContext(), banners.get(position).getImgUrl(), imageView);
        container.addView(view);
        return view;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return false;
    }


}
